﻿namespace Borg.AddOn
{
    internal sealed class ComposerSubstitutionHookChain : IComposerSubstitutionHook
    {
        private readonly IComposerSubstitutionHook[] _substitutionHooks;

        public ComposerSubstitutionHookChain(IComposerSubstitutionHook[] substitutionHooks)
        {
            _substitutionHooks = substitutionHooks;
        }

        public void SubstituteForPlugging(ref Slot slot, ref Plug plug)
        {
            foreach (IComposerSubstitutionHook hook in _substitutionHooks)
                hook.SubstituteForPlugging(ref slot, ref plug);
        }

        public void SubstituteForTagging(ref Slot slot, ref Plug plug, ref string tag)
        {
            foreach (IComposerSubstitutionHook hook in _substitutionHooks)
                hook.SubstituteForTagging(ref slot, ref plug, ref tag);
        }

        public void SubstituteForUnplugging(ref Slot slot, ref Plug plug)
        {
            foreach (IComposerSubstitutionHook hook in _substitutionHooks)
                hook.SubstituteForUnplugging(ref slot, ref plug);
        }

        public void SubstituteForUntagging(ref Slot slot, ref Plug plug, ref string tag)
        {
            foreach (IComposerSubstitutionHook hook in _substitutionHooks)
                hook.SubstituteForUntagging(ref slot, ref plug, ref tag);
        }
    }
}
